package com.sphd.emanu.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.emanu.R;
import com.sphd.emanu.pojo.bank.BankListInfo;

import java.util.List;

/**
 * @Author Hu
 * @Time 2017/7/24 --17:56.
 * @Email 87683202@qq.com
 */
public class BankListAdapter extends BaseQuickAdapter<BankListInfo, BaseViewHolder> {
    Context context;

    public BankListAdapter(@LayoutRes int layoutResId, @Nullable List<BankListInfo> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, BankListInfo financeAccountListBean) {
        helper
                .setText(R.id.bankcard_name_textview, financeAccountListBean.getBankName().equals("") ? financeAccountListBean.getName() :
                        financeAccountListBean.getBankName())
                .setText(R.id.bank_money, financeAccountListBean.getBankName().equals("") ? "现金" :
                        "Bank")
                .setText(R.id.card_num_textview, financeAccountListBean.getAccount());
        CardView cardViewBankMoney = helper.getView(R.id.cardview_bank_money);

        if (financeAccountListBean.getOperation().equals("基本户")) {
            cardViewBankMoney.setCardBackgroundColor(context.getResources().getColor(R.color.colorPrimary));
        } else {
            cardViewBankMoney.setCardBackgroundColor(context.getResources().getColor(R.color.steelblue));
        }


    }
}
